package org.egedede.gravity.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Random;

/**
 * The Class RandomGravitySystem.
 */
public class RandomGravitySystem extends GravitySystem{

	/**
	 * Instantiates a new random gravity system.
	 */
	public RandomGravitySystem(){
		super();
		setConstant(1);
		initBodies();
	}

	/**
	 * Inits the bodies.
	 */
	private void initBodies() {
		int size = 20;
		Collection<Body> bodies = new ArrayList<Body>(size);
		Random random = new Random(System.currentTimeMillis());
		for(int i=0;i<size;i++){
			Body body =  new Body();
			body.setLabel("body "+i);
			body.setAx(0);
			body.setAy(0);
			body.setVx(0);
			body.setVy(0);
			body.setMass((int)(random.nextDouble()*100));
			body.setX((int)(random.nextDouble()*2000)-1000);
			body.setY((int)(random.nextDouble()*2000)-1000);
			bodies.add(body);
		}
		Body body = new Body();
		body.setLabel("Center");
		body.setAx(0);
		body.setAy(0);
		body.setVx(0);
		body.setVy(0);
		body.setMass(100);
		body.setX(0);
		body.setY(0);
		bodies.add(body);
		setBodies(bodies);
	}
}
